/*
 * @Author: 胡海
 * @Date: 2020-02-21 18:23:26
 * @LastEditors: 胡海
 * @LastEditTime: 2020-03-07 21:17:44
 * @Description: 
 */
const {
    sequelize
} = require('../../core/db.js')


const {
    Sequelize,
    Model,
    Op
} = require('sequelize')

const {
    Wgoods
} = require('./w-goodsM')

// define
class Wimg extends Model {
    static async addImg(img, v) { // 新增
        let request = {
            img,
            uid: v.get('body.id')
        }
        Wimg.create(request)
    }

    static async list(v) { // 查询
        let request = {
            uid: v.id
        }
        const info = await Wimg.findAll({
            where: {
                uid: request.uid
            }
        })
        return info
    }
}

Wimg.init({
    img: Sequelize.STRING,
    uid: Sequelize.STRING
}, {
    sequelize,
    tableName: 'Wimg',
    alter: true
})

module.exports = {
    Wimg
}

// 数据迁移 SQL 更新 风险